/**
 * Creat with IntelliJ IDEA
 * Description
 * User: mamba24
 * Date: 2022-07-24
 * Time: 15:02
 * To BE A Better Person-2020-3-2
 */
public class TestDemo3 {
    public static void main(String[] args) throws InterruptedException{
        Thread t = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                System.out.println("i'm Thread");
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                   // e.printStackTrace();
                    //1.立即退出
                    //break;
                    //2.进行收尾工作
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException ex) {
                        ex.printStackTrace();
                    }
                }
            }
        });
        t.start();
        Thread.sleep(5000);
        System.out.println("i'm main");
        t.interrupt();
    }
}


